﻿using MediatR;
using T_settlement.API.Application.Command.PaymentCommand;
using T_settlement.Infrastructure.Interfacec;

namespace T_settlement.API.Application.CommandHandlers.PaymentCommandHandlers
{
    public class DelPaymentCommandHandlers:IRequestHandler<DelPaymentCommand,int>
    {
        private readonly IPaymentRepository paymentRepository;

        public DelPaymentCommandHandlers(IPaymentRepository paymentRepository)
        {
            this.paymentRepository = paymentRepository;
        }

        public async Task<int> Handle(DelPaymentCommand request, CancellationToken cancellationToken)
        {
            var list = await paymentRepository.GetModelAsync(request.PaymentId);
            list.IsDel=true;
            var res=  await paymentRepository.UpdateAsync(list);
            return res;
        }
    }
}
